1. Problem
You need to understand how to
use the Facts Explorer to create a vocabulary that will be used within a
business rule fact. You want to be able to store constants, predicates,
and so on, that can be changed easily without redeploying code.
2. Solution
This solution will demonstrate how to create a vocabulary using a node in an imported XML schema. Facts are those items that are used to create rules. The Facts Explorer has four tabs, as follows:
Vocabularies:
These consist of all defined values that you can use when creating a
rule, including constants, predicates, XML nodes, and so on.
XML Schemas:
You can use all schemas imported onto this tab when creating
vocabularies or predicates (actions). You can drag and drop nodes on the
XML Schemas tab in the Vocabulary window.
Databases:
You can add references to databases that will be used for creating
facts on this tab. You can drag and drop tables onto the Vocabulary
window.
NET Assemblies: Assemblies, like databases and XML schemas, can be references in the Facts Explorer and used to create vocabularies.
Use the following steps to import an XML schema and create a new vocabulary:
In the BizTalk Business Rule Composer, click the XML Schemas tab in the Facts Explorer.
Right-click the Schemas folder, and select Browse. Locate a schema to import, and click Open. This imports the full schema into the window.
Create a new vocabulary by clicking the Vocabulary tab. Right-click the Vocabularies folder, and select Add New Vocabulary. Give the vocabulary a name.
Now,
drag a node from the XML schema that was imported, and drop it on the
vocabulary you created in the previous step. By holding down the mouse
button as you drag the node, you can navigate between tabs.
The
Vocabulary Definition Wizard immediately opens, with the XML Document
or Attribute option automatically selected. Navigate through the wizard
to finish creating the vocabulary. The fields will already be filled in
for you.
3. How It Works
You can add the Database
and .NET Assembly facts to the Vocabulary tab in a similar manner as
described in this solution. Additionally, you can drop all facts in the
condition or action (IF...THEN) of a rule.
Once you have added a fact to a rule, right-clicking the condition or
action allows you to browse to the original fact, as shown in Figure 1. Complex rules will have many facts referenced in them, and this allows you to keep track of all the disparate definitions.